package cn.script.domain;


/**
 * 技能
 *
 * @author 周永波
 */
public class Skill {

    public final static Skill defaultSkill = new Skill("f4", 0, 50);

    private String key = "f4";
    /**
     * 0: 指向技能  1:选中技能
     */
    private int type = 1;

    /**
     * 技能冷却
     */
    private int delay;

//    private RangePoint defaultRange = new RangePoint(314, 133, 481, 329);

    private RangePoint defaultRange = new RangePoint(237, 168, 647, 364);

    private SkillInfo skillInfo;

    public Skill(String key, int type, int delay) {
        this.key = key;
        this.type = type;
        this.delay = delay;
    }


    public Skill skillInfo(SkillInfo skillInfo) {
        this.skillInfo = skillInfo;
        return this;
    }

    public int type() {
        return this.type;
    }

    public String key() {
        return this.key;
    }

    /**
     * 是否可以是否技能
     *
     * @param time
     * @return
     */
    public boolean isRelease(int time) {
        int n = time / this.delay;
        if (n > this.skillInfo.num ||  this.skillInfo.num == 0) {
            this.skillInfo.num ++;
            return true;
        }
        return false;
    }


    public void release(int time) {
        if (!this.isRelease(time)) {
            return;
        }
    }

    public RangePoint range() {
        return this.defaultRange;
    }

    public static class SkillInfo {
        public int num = 0;
    }
}
